<?php

/**
 * ChecklistController - Checklist
 *
 * @author Fernando Dias Oliveira <rodox17@gmail.com>
 * @package intranet
 * @subpackage controller
 */

class ChecklistController extends AppBaseController
{
	public function init()
	{
		parent::init();
		
		$this->view->title = "Checklist";		
		
		if($this->_request->isPost())
		{
			extract($_POST, EXTR_OVERWRITE);
			
			$documento = new INT015();
			
			$documento->setINT015_cod($cod);
			$documento->setINT015_nome($INT015_nome);
			$documento->setINT015_url(Upload::save());
			$documento->setINT015_descricao($INT015_descricao);
			
			$documento->save();
			
			$this->_redirect("/$this->controller/");
		}
	}

    public function indexAction() 
    {
		$this->grid("INT015");
    }
    
    public function adicionarAction()
    {
    	
    }
    
    public function excluirAction()
    {
    	$documento = new INT015();
    	
    	$id = $this->getArrCod($this->_request->getParam("cod"));
    	
    	$documento->excluir($id);
    	
    	$this->_redirect("/$this->controller/");
    }
    
    public function editarAction()
    {
		$INT015 = new INT015();

		$cod = $this->_request->getParam("cod");
		
		$this->view->r = $INT015->getById($cod);
    }
    
    public function abrirAction()
    {
		$INT015 = new INT015();

		$cod = $this->_request->getParam("cod");
		
		$this->view->r = $INT015->getById($cod);
    }
    
    public function duplicarAction()
    {
		$INT015 = new INT015();

		$cod = $this->_request->getParam("cod");
		
		$arr = $INT015->getById($cod);
		
		unset($arr["INT015_cod"]);
		
		$this->view->r = $arr;
    	
    }
    
    public function downloadAction()
    {
    	$documento = new INT015();
    	
    	$id = $this->getArrCod($this->_request->getParam("cod"));
    	
    	$doc = $documento->getDocumentoById(key($id));    	
    	
    	$this->view->doc = $doc[0];
    }
}

?>